<template>
  <div class="body">
    <el-container>
      <!-- 头部导航栏 -->
      <el-header>
        <Index></Index>
      </el-header>
      <!-- 左侧边栏 -->

      <el-container>
        <el-container>
          <el-main>
            <el-row style="margin-bottom:20px;">
              <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">
                  <font color="#A1FEDB" size="4">综合分析</font>
                </el-breadcrumb-item>
                <el-breadcrumb-item>
                  <font color="#A1FEDB" size="4">综合能效分析</font>
                </el-breadcrumb-item>
              </el-breadcrumb>
            </el-row>
            <el-row>
              <el-tabs tab-position="top" v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="综合能效分析" name="first">
                  <div id="allmap">
                    <el-row>
                      <el-col :span="12">
                        <el-row>
                          <!-- <div class="newbutton" @click="handle_replace"></div> -->
                          <span style="color:#90F0D0;font-size:2rem;font-weight:blod;">能效分析曲线</span>
                        </el-row>
                        <el-row>
                          <div id="topology-canvas" class="full"></div>
                        </el-row>
                      </el-col>
                      <el-col :span="12">
                        <el-row>
                          <span style="color:#90F0D0;font-size:2rem;font-weight:blod;">能效信息统计</span>
                        </el-row>
                        <el-row>
                          <div id="table4">
                            <el-row>
                              <el-col :span="12">
                                <el-row style="margin-top:10px;">
                                  <center>
                                    <font color="white" size="3">本日能效统计</font>
                                  </center>
                                </el-row>
                                <el-row>
                                  <el-form
                                    :model="formInline"
                                    :label-position="right"
                                    size="mini"
                                    style="margin-top:10px;margin-right:80px;"
                                  >
                                    <el-form-item label="清洁能源消纳率" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data1"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="清洁能源发电量占比" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data2"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="电能占终端能源消费比重" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data3"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="系统综合能效比" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data4"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="三联供综合利用效率" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data4"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                  </el-form>
                                </el-row>
                              </el-col>
                              <el-col :span="12">
                                <el-row style="margin-top:10px;">
                                  <center>
                                    <font color="white" size="3">本月能效统计</font>
                                  </center>
                                </el-row>
                                <el-row>
                                  <el-form
                                    :model="formInline"
                                    :label-position="right"
                                    size="mini"
                                    style="margin-top:10px;margin-right:80px;"
                                  >
                                    <el-form-item label="清洁能源消纳率" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data5"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="清洁能源发电量占比" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data6"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="电能占终端能源消费比重" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data7"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="系统综合能效比" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data8"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                    <el-form-item label="三联供综合利用效率" label-width="180px">
                                      <el-input
                                        class="input5"
                                        v-model="formInline.data9"
                                        placeholder
                                      ></el-input>
                                    </el-form-item>
                                  </el-form>
                                </el-row>
                              </el-col>
                            </el-row>
                          </div>
                        </el-row>
                      </el-col>
                    </el-row>
                    <el-row>
                      <div>
                        <el-row>
                          <el-col :span="12">
                            <el-row>
                              <span style="color:#90F0D0;font-size:2rem;font-weight:blod;">系统月度能效对标</span>
                            </el-row>
                            <div id="table1">
                              <el-table
                                :data="tableData1"
                                style="width: 100%"
                                :row-style="getRowClass"
                                :header-row-style="getRowClass"
                                :header-cell-style="getRowClass2"
                                @cell-mouse-enter="changerow"
                              >
                                <el-table-column prop="序号" label="序号"></el-table-column>
                                <el-table-column prop="能效指标名称" label="能效指标名称"></el-table-column>
                                <el-table-column prop="本日能效值" label="本日能效值"></el-table-column>
                                <el-table-column prop="本月日最高能效值" label="本月日最高能效值"></el-table-column>
                                <el-table-column prop="最高值时间" label="最高值时间"></el-table-column>
                              </el-table>
                            </div>
                          </el-col>
                          <el-col :span="6">
                            <el-row>
                              <span style="color:#90F0D0;font-size:2rem;font-weight:blod;">本月负荷用电量占比</span>
                            </el-row>
                            <div id="table3"></div>
                          </el-col>
                          <el-col :span="6">
                            <el-row>
                              <span
                                style="color:#90F0D0;font-size:2rem;font-weight:blod;"
                              >日最大用电量时各负荷占比</span>
                            </el-row>
                            <div id="table23"></div>
                          </el-col>
                        </el-row>
                      </div>
                    </el-row>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </el-row>
          </el-main>
        </el-container>
      </el-container>

      <!-- 表格显示区 -->

      <Bottom></Bottom>
    </el-container>
  </div>
</template>
<script>
import echarts from 'echarts'

import CanvasProps from '~/components/CanvasProps'
import CanvasContextMenu from '~/components/CanvasContextMenu'
import Index from '~/components/index2'
import Bottom from '~/components/bottom'
export default {
  data() {
    return {
      labelPosition: 'right',
      formInline: {
        data1: '',
        data2: '',
        data3: '',
        data4: '',
        data5: '',
        data6: '',
        data7: '',
        data8: '',
        data9: '',
        data10: ''
      },
      formInline2: {
        data1: '',
        data2: '',
        data3: '',
        data4: ''
      },
      formInline3: {
        data1: '',
        data2: '',
        data3: '',
        data4: ''
      },
      power1: '',
      power2: '',
      power3: '',
      power4: '',
      power5: '',
      power6: '',
      power7: '',
      tableData1: [],

      labelPosition: 'left',

      activeIndex: '3',

      activeName: 'first',
      activeName2: '1'
    }
  },
  components: {
    Index,
    Bottom
  },
  computed: {},

  created() {},

  mounted() {
    this.readdata()
    this.laterpowercurve()
  },

  methods: {
    //获取页面所需数据
    readdata() {
      this.$axios({
        method: 'get',
        params: {},
        url: 'http://127.0.0.1:8082/comprehensive/efficiency'
      }).then(res => {
        //能效信息统计
        this.formInline.data1 = res.data[0][0]
        this.formInline.data2 = res.data[0][1]
        this.formInline.data3 = res.data[0][2]
        this.formInline.data4 = res.data[0][3]
        this.formInline.data5 = res.data[0][4]
        this.formInline.data6 = res.data[0][5]
        this.formInline.data7 = res.data[0][6]
        this.formInline.data8 = res.data[0][7]
        this.formInline.data9 = res.data[0][8]
        this.formInline.data10 = res.data[0][9]
        //能效曲线分析
        this.power1 = res.data[1][0]
        this.power2 = res.data[1][1]
        this.power3 = res.data[1][2]
        this.power4 = res.data[1][3]
        this.power5 = res.data[1][4]
        //直通月度能效对标
        this.tableData1 = res.data[2]
        //本月负荷用电量占比
        this.formInline2.data1 = res.data[3][0][0]
        this.formInline2.data2 = res.data[3][0][1]
        this.formInline2.data3 = res.data[3][0][2]
        this.formInline2.data4 = res.data[3][0][3]
        //日最大用电量时各负荷占比
        this.formInline3.data1 = res.data[3][1][0]
        this.formInline3.data2 = res.data[3][1][1]
        this.formInline3.data3 = res.data[3][1][2]
        this.formInline3.data4 = res.data[3][1][3]
      })
    },
    //延迟执行函数
    laterpowercurve() {
      setTimeout(() => {
        this.showecharts()
      }, 5000)
    },
    showecharts() {
      let myChart1 = this.$echarts.init(
        document.getElementById('topology-canvas')
      )
      let option1 = {
        title: {
          text: ''
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {
          data: [
            '清洁能源消纳率',
            '清洁能源发电量占比',
            '电能占终端能源消费比重',
            '系统综合能效比',
            '三联供系统综合利用效率'
          ],
          textStyle: {
            color: 'white' // 图例文字颜色
          }
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            name: '/天',
            boundaryGap: false,
            data: [
              '1',
              '2',
              '3',
              '4',
              '5',
              '6',
              '7',
              '8',
              '9',
              '10',
              '11',
              '12',
              '13',
              '14',
              '15',
              '16',
              '17',
              '18',
              '19',
              '20',
              '21',
              '22',
              '23',
              '24',
              '25',
              '26',
              '27',
              '28',
              '29',
              '30'
            ],
            axisLine: {
              lineStyle: {
                color: 'white',
                width: 1 //这里是为了突出显示加上的
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: {
              lineStyle: {
                color: 'white',
                width: 1 //这里是为了突出显示加上的
              }
            }
          }
        ],
        series: [
          {
            name: '清洁能源消纳率',
            type: 'line',

            smooth: true, //曲线平滑
            itemStyle: {
              normal: {
                //颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: '#d7f4f8' // 0% 处的颜色
                  },
                  {
                    offset: 0.5,
                    color: '#eefcfd' // 100% 处的颜色
                  },
                  {
                    offset: 1,
                    color: '#fff' // 100% 处的颜色
                  }
                ]), //背景渐变色
                lineStyle: {
                  // 系列级个性化折线样式
                  width: 3,
                  type: 'solid',
                  color: '#4fd6d2'
                }
              },
              emphasis: {
                color: '#4fd6d2',
                lineStyle: {
                  // 系列级个性化折线样式
                  width: 2,
                  type: 'dotted',
                  color: '#4fd6d2' //折线的颜色
                }
              }
            }, //线条样式
            symbolSize: 5, //折线点的大小

            areaStyle: {
              opacity: 0.3
              // color: '#fff'
            },
            stack: '',
            areaStyle: {},
            data: this.power1
          },
          {
            name: '清洁能源发电量占比',
            type: 'line',
            smooth: true, //曲线平滑
            stack: '',
            areaStyle: {},
            data: this.power2
          },
          {
            name: '电能占终端能源消费比重',
            type: 'line',
            smooth: true, //曲线平滑
            stack: '',
            areaStyle: {},
            data: this.power3
          },
          {
            name: '系统综合能效比',
            type: 'line',
            smooth: true, //曲线平滑
            stack: '',
            areaStyle: {},
            data: this.power4
          },
          {
            name: '三联供系统综合利用效率',
            type: 'line',
            smooth: true, //曲线平滑
            stack: '',
            areaStyle: {},
            data: this.power5
          }
        ]
      }

      myChart1.setOption(option1)
      //建议加上以下这一行代码，不加的效果图如下（当浏览器窗口缩小的时候）。超过了div的界限（红色边框）
      window.addEventListener('resize', function() {
        myChart1.resize()
      })
      //
      //发用电计划

      let myChart3 = this.$echarts.init(document.getElementById('table3'))
      let option3 = {
        title: {
          text: '',
          subtext: '',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
          data: [
            {
              name: '充电桩',
              icon: 'circle',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '直流配电室',
              icon: 'rect',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '交流配电室',
              icon: 'roundRect',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '室内直流负荷',
              icon: 'triangle',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            }
          ]
        },
        series: [
          {
            name: '用电比例',
            type: 'pie',
            radius: '55%',
            center: ['50%', '60%'],
            data: [
              { value: this.formInline2.data1, name: '充电桩' },
              { value: this.formInline2.data2, name: '直流配电室' },
              { value: this.formInline2.data3, name: '交流配电室' },
              { value: this.formInline2.data4, name: '室内直流负荷' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      myChart3.setOption(option3)
      //建议加上以下这一行代码，不加的效果图如下（当浏览器窗口缩小的时候）。超过了div的界限（红色边框）
      window.addEventListener('resize', function() {
        myChart3.resize()
      })
      let myChart23 = this.$echarts.init(document.getElementById('table23'))
      let option23 = {
        title: {
          text: '',
          subtext: '',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
          data: [
            {
              name: '充电桩',
              icon: 'circle',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '直流配电室',
              icon: 'rect',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '交流配电室',
              icon: 'roundRect',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            },
            {
              name: '室内直流负荷',
              icon: 'triangle',
              textStyle: {
                color: 'white' // 图例文字颜色
              }
            }
          ]
        },
        series: [
          {
            name: '用电比例',
            type: 'pie',
            radius: '55%',
            center: ['50%', '60%'],
            data: [
              { value: this.formInline3.data1, name: '充电桩' },
              { value: this.formInline3.data2, name: '直流配电室' },
              { value: this.formInline3.data3, name: '交流配电室' },
              { value: this.formInline3.data4, name: '室内直流负荷' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      myChart23.setOption(option23)
      //建议加上以下这一行代码，不加的效果图如下（当浏览器窗口缩小的时候）。超过了div的界限（红色边框）
      window.addEventListener('resize', function() {
        myChart23.resize()
      })
    },
    openDetails(a, b) {
      this.$router.push({ path: '/healthdiagnosis/diagnosisdetails' })
    },
    async open() {
      if (!this.$route.query.id) {
        return
      }
      const data = await this.$axios.$get(
        '/api/topology/' + this.$route.query.id
      )
      if (data && data.id) {
        this.canvas.open(data.data)
      }
    },
    getRowClass({ row, column, rowIndex, columnIndex }) {
      // return 'background:#444444;color:#18EFF2;'
      return 'background:#053030;color:#18EFF2;'
    },
    //设置表头颜色和背景
    getRowClass2({ row, column, rowIndex, columnIndex }) {
      // return 'background:#444444;color:#18EFF2;'
      return 'background:#053030;color:#18EFF2;'
    },
    getRowClass3({ row, column, rowIndex, columnIndex }) {
      // return 'background:#444444;color:#F50C0C;'
      return 'background:#053030;color:#18EFF2;'
    },
    handleDelete(index, row) {
      alert(index)
      //  this.$router.push({path:'/details',query: {id:item.device_id}})
      this.$router.push({ path: '/indexx' })
      console.log(index, row)
    },
    handleClick(tab, event) {
      console.log(tab, event)
    },

    logout() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
    },

    infoWindowClose(i) {
      //  alert("关闭提示窗"+i.showFlag)
      return (i.showFlag = false)
    },
    infoWindowOpen(i) {
      // alert("打开提示窗"+i.showFlag)
      return (i.showFlag = true)
    },
    opencarinfo(item) {
      //  this.$router.push({name:'details',params: {id:'1'}})
      // alert("执行")

      this.$router.push({ path: '/details', query: { id: item.device_id } })
    },

    handle_new(data) {
      this.canvas.open({ nodes: [], lines: [] })
    },

    handle_open(data) {
      this.handle_replace(data)
    },

    handle_replace(data) {
      const input = document.createElement('input')
      input.type = 'file'
      input.onchange = event => {
        const elem = event.srcElement || event.target
        if (elem.files && elem.files[0]) {
          const name = elem.files[0].name.replace('.json', '')
          const reader = new FileReader()
          reader.onload = e => {
            const text = e.target.result + ''
            try {
              const data = JSON.parse(text)
              if (
                data &&
                Array.isArray(data.nodes) &&
                Array.isArray(data.lines)
              ) {
                this.canvas.open(data)
              }
            } catch (e) {
              return false
            }
          }
          reader.readAsText(elem.files[0])
        }
      }
      input.click()
    },

    handle_save(data) {
      FileSaver.saveAs(
        new Blob([JSON.stringify(this.canvas.data)], {
          type: 'text/plain;charset=utf-8'
        }),
        // `le5le.topology.json`
        `11111.json`
      )
    },

    handle_savePng(data) {
      this.canvas.saveAsImage('le5le.topology.png')
    }
  }
}
</script>
<style lang="scss">
.el-tabs {
  width: 100%;
  color: white;
  background-image: url(../../assets/images/新UI12.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.el-tabs__item {
  padding: 0 20px;
  height: 40px;
  box-sizing: border-box;
  line-height: 40px;
  display: inline-block;
  list-style: none;
  font-size: 14px;
  font-weight: 500;
  color: #e3e5ea;
  position: relative;
}
.el-table {
  background-color: #032121;
}
.input2 .el-input__inner {
  width: 5rem;
  height: 2.5rem;

  // border-radius: 4px;
  // border: 1px solid #b6d8f1;
  // color: #6a6f77;
  // outline: 0;
  // background-color: #062e2f;
}
</style>
<style lang="scss" scoped>
.body {
  width: 100%;
  height: 100%;
  margin-top: 0px;
  background-image: url(../../assets/images/新UI12.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
#topology-canvas {
  width: 99%;
  height: 333px;
  background-image: url(../../assets/images/新UI16.png);
}
#table11 {
  width: 99%;
  height: 333px;
  background-image: url(../../assets/images/新UI16.png);
}
//控制画布的大小
.full {
  flex: 1;
  width: initial;
  position: relative;
  overflow: auto;
  background: #fff;
  // background-image: url("+require('../assets/images/timg.jpg')")
}

#table1 {
  width: 99%;
  height: 333px;
  //
  background-image: url(../../assets/images/新UI16.png);
}

#table2 {
  width: 95%;
  height: 389px;

  background-color: #005b5c;
  background-image: url(../../assets/images/新UI46.png);
}

#table3 {
  width: 95%;
  height: 333px;
  margin-left: 3rem;
  background-image: url(../../assets/images/新UI16.png);
}
#table23 {
  width: 95%;
  height: 333px;
  margin-left: 1rem;
  background-image: url(../../assets/images/新UI16.png);
}
#table4 {
  width: 100%;
  height: 333px;

  margin-left: 3rem;

  background-image: url(../../assets/images/新UI16.png);
}
#table24 {
  width: 100%;
  height: 333px;
}
#table12 {
  width: 100%;
  height: 333px;

  margin-left: 3rem;

  background-image: url(../../assets/images/新UI16.png);
}
#table13 {
  width: 99%;
  height: 333px;
  //
  background-image: url(../../assets/images/新UI16.png);
}
#table14 {
  width: 95%;
  height: 333px;
  margin-left: 3rem;
  background-image: url(../../assets/images/新UI16.png);
}
#allmap {
  // height: 600px;
  // color: white;
  margin-top: 20px;
}
.newbutton {
  width: 284px;
  height: 48px;
  background-image: url(../../assets/images/新UI43.png);
  // border-color: #041214;
  display: inline-block;
}

.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
</style>
